/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TagFeatureList.java
 *
 * Created on 28-Jun-2010, 04:27:52
 */

package camp.junk;

import campskeleton.CampSkeleton;
import javax.swing.DefaultListModel;
import straightskeleton.Tag;

/**
 *
 * @author twak
 */
public class TagFeatureList extends javax.swing.JPanel {
    /** Creates new form TagFeatureList */
    public TagFeatureList() {
        initComponents();
    }

    TagFeatureList(Tag ... features) {
        initComponents();
        DefaultListModel lm = new DefaultListModel();
        for (Tag f : features)
            lm.addElement( f );

        tagList.setModel(lm);
        tagList.setSelectedIndex(0);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tagList = new javax.swing.JList();
        jSeparator1 = new javax.swing.JSeparator();

        tagList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                tagListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(tagList);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void tagListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_tagListValueChanged
        Tag f = (Tag)tagList.getSelectedValue();
//        CampSkeleton.instance.setSelectedFeature(f); // may be null ;)
    }//GEN-LAST:event_tagListValueChanged


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JList tagList;
    // End of variables declaration//GEN-END:variables

}
